package com.jphoebe.plugin.mybatis.utils;

import cn.hutool.core.io.resource.ClassPathResource;
import cn.hutool.setting.Setting;
import cn.hutool.setting.SettingUtil;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * 国际化工具
 *
 * @author 蒋时华
 * @date 2019/2/20
 */
public class Il8nUtil {

    public final static Integer ZH_CN = 0;
    public final static Integer EN_US = 1;

    public static Setting getCurrnetSysProp(Integer il8n){
        Locale locale = Il8nUtil.getLocale(il8n);
        String path = "language/language_"+locale.getLanguage()+"_"+locale.getCountry()+".properties";
        return PropertiesUtil.getPorps(path);
    }

    public static Locale getLocale(Integer il8n){
        if(ZH_CN.equals(il8n)){
            return new Locale("zh","CN");
        }else if(EN_US.equals(il8n)){
            return new Locale("en", "US");
        }else{
            return Locale.getDefault();
        }
    }

}
